'use strict';

/**
 * @ngdoc overview
 * @name App
 * @description
 * # App
 *
 * Main module of the application.
 */
angular
  .module('App', [
    'ngAnimate',
    'ngMessages',
    'ngResource',
    'ngSanitize',
    'ui.router',
    'ui.bootstrap',
    'ui.utils',
    'ui.select',
    'checklist-model'
  ])
  .constant('EXAM_WORK_API', 'http://127.0.0.1:8003/api/ecs_exam_work')
  .constant('EXAM_SERVER', 'http://127.0.0.1:8003/api/ecs_exam_work')
/**
 * 初始化配置
 */
  .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider
      .otherwise('access/login');

    $stateProvider
    /**
     * 允许访问的模块
     */
      .state('access', {
        url: '/access',
        template: '<div data-ui-view class="fade-in-right smooth"></div>'
      })

    /**
     * 登录
     */
      .state('access.login', {
        url: '/login',
        templateUrl: 'views/access/login.html',
        controller: 'LoginCtrl',
        resolve: {
          data: ['MultiData', function(MultiData) {
            return MultiData(500);
          }]
        }
      })

    /**
     * 首页
     */
      .state('app', {
        abstract: true,
        url: '/app',
        templateUrl: 'views/app.html'
      })

    /**
     * 用户管理
     */
      .state('app.users', {
        url: '/users',
        templateUrl: 'views/user/users.html',
        resolve: {
          data: ['MultiData', function(MultiData) {
            return MultiData(500);
          }]
        }
      })

    /**
     * 考生信息管理
     */
      .state('app.studentPhoto', {
        //考生管理,test merge
        url: '/students',
        controller: 'StudentsController',
        templateUrl: 'views/studentPhoto/studentPhoto.html',
        resolve: {
      }
      })

  }])

/**
 * 模拟数据
 */
  .factory('MultiData', ['$timeout', function($timeout) {
    return function(times) {
      return $timeout(function() {
        return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
      }, times);
    };
  }])

/**
 * 全局控制器
 */
  .controller('AppController', ['$scope', '$state', function($scope, $state) {
    $scope.app = {
      name: '后台管理系统',
      version: '1.3.2',
      // for chart colors
      color: {
        primary: '#7266ba',
        info:    '#23b7e5',
        success: '#27c24c',
        warning: '#fad733',
        danger:  '#f05050',
        light:   '#e8eff0',
        dark:    '#3a3f51',
        black:   '#1c2b36'
      },
      settings: {
        themeID: 1,
        navbarHeaderColor: 'bg-black',
        navbarCollapseColor: 'bg-white-only',
        asideColor: 'bg-black',
        headerFixed: true,
        asideFixed: true,
        asideFolded: false,
        asideDock: false,
        container: false
      }
    };
  }])

/**
 * 启动函数
 */
  .run(['$rootScope', '$state', function($rootScope, $state) {
    $rootScope.$state = $state;
    $rootScope.$stateParams = $state.params;
  }]);
